﻿using System;
using System.Web.Mvc;
using MyAlbum.Logging;

namespace PersonalAlbum.Controllers
{
    public class RssController : Controller
    {
        [AcceptVerbs(HttpVerbs.Get)]
        [OutputCache(Duration = 3600, VaryByParam = "lang")]
        public TextResult Index(string lang)
        {
            WebLogger.Trace("rss index");
            try
            {
                UrlHelper url = new UrlHelper(new System.Web.Routing.RequestContext(this.HttpContext, this.RouteData));
               
                Response.ContentType = "text/xml";
                Response.ContentEncoding = System.Text.Encoding.UTF8;
                return new TextResult(RssFormatter.GetRssFeed(url));
            }
            catch (Exception e1)
            {
                WebLogger.LogError(e1, "rss");
                return new TextResult("An error occurred");
            }
        }
    }
}
